--------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  X:\shared\ambulance\Work\replicationpackage\logs\district_regressions.log
  log type:  text
 opened on:  13 Jul 2024, 07:39:48

. 
. /*******************************************************************************
> district_regressions.do
> 
> Analyzes district-level data
> *******************************************************************************/
. 
. clear all

. 
. use "${cleandatapath}dist_data.dta", clear

. 
. qui {

. 
. qui reghdfe log_tot_pmt ib99.months_since_PA100 i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since Prior Authorization Implementation) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_3.pdf, as(pdf)  replace // Figure 3

. 
. qui reghdfe log_tot_pmt ib99.months_since_civ100 i.prior_auth i.post_crim, a(dist_code month_date) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since First Civil Enforcement) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_4a.pdf, as(pdf)  replace // Figure 4a

. 
. qui reghdfe log_tot_pmt ib99.months_since_crim100 i.prior_auth i.post_civ, a(dist_code month_date) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since First Criminal Enforcement) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_4b.pdf, as(pdf)  replace // Figure 4b

. 
. qui reghdfe log_active_firms ib99.months_since_PA100_firm i.post_crim i.post_civ if month_date>=624, a(dist_code month_date) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since Prior Authorization Implementation) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Active Firms in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_6.pdf, as(pdf)  replace // Figure 6

. 
. qui reghdfe log_tot_pmt ib99.months_since_civ100 i.prior_auth i.post_crim if  months_since_civ100!=50, a(dist_code) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since First Civil Enforcement) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_A8a.pdf, as(pdf)  replace // Figure A8a

. 
. qui reghdfe log_tot_pmt ib99.months_since_crim100 i.prior_auth i.post_civ if months_since_crim100!=50, a(dist_code) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since First Criminal Enforcement) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_A8b.pdf, as(pdf)  replace // Figure A8b

. 
. qui reghdfe log_tot_pmt ib99.months_since_civ100 i.prior_auth i.post_crim if first_civil_spill!=0 | !missing(civ_date), a(dist_code month_date) vce(cl
> uster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since First Civil Enforcement) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_A9a.pdf, as(pdf)  replace // Figure A9a

. 
. qui reghdfe log_tot_pmt ib99.months_since_crim100 i.prior_auth i.post_civ if first_criminal_spill!=0 | !missing(crim_date), a(dist_code month_date) vc
> e(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since First Criminal Enforcement) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_A9b.pdf, as(pdf)  replace // Figure A9b

. 
. qui reghdfe log_tot_pmt ib99.months_since_PA100 i.post_crim i.post_civ if month_date>=612 & PA_wave!=2, a(dist_code month_date) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since Prior Authorization Implementation) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_A10a.pdf, as(pdf)  replace // Figure A10a

. 
. qui reghdfe log_tot_pmt ib99.months_since_PA100 i.post_crim i.post_civ if month_date>=612 & PA_wave!=1, a(dist_code month_date) vce(cluster dist_code)

. coefplot, keep(*months_since*) vert baselevel ///
>         recast(connected) ciopts(recast(rcap) color(navy)) ///
>         xti(Months Since Prior Authorization Implementation) ///
>         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                 31 "6" 37 "12" 43 "18" 49 "24") ///
>         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>         yti("Total Payments in District (Logs)") ///
>         ylab(, angle(0)) ///
>         graphregion(color(white)) bgcolor(white)

. qui graph export ${outpath}Figure_A10b.pdf, as(pdf)  replace // Figure A10b

. 
. label var tot_pmt "\shortstack{Total Ride \\ Payments}"

. label var log_tot_pmt "\shortstack{Total Ride \\ Payments (Log)}"

. label var ambulance_id "\shortstack{Total \\ Rides}"

. label var log_rides "\shortstack{Total \\ Rides (Log)}"

. label var active_firms "\shortstack{Active \\ Firms}"

. label var log_active_firms "\shortstack{Active \\ Firms (Log)}"

. label var ihs_pmt "\shortstack{Total Ride \\ Payments (IHS)}"

. label var ihs_rides "\shortstack{Total \\ Rides (IHS)}"

. label var ihs_firms "\shortstack{Active \\ Firms (IHS)}"

. label var emerg_pmt "\shortstack{Payments for \\ Emergency Rides}"

. label var log_emerg_pmt "\shortstack{Payments for \\ Emergency Rides (Log)}"

. label var emerg_rides "\shortstack{Total Emergency \\ Rides}"

. label var log_emerg_rides "\shortstack{Total Emergency \\ Rides (Log)}"

. 
. qui bysort dist_code: egen base_ridess=mean(ambulance_id) if year<=2005

. bysort dist_code: egen base_rides=max(base_ridess)

. gen anylit=(months_since_civ!=-50 | months_since_crim!=-50)

. 
. qui {

. 
. di exp(-1.129)-1 // Referenced in Section 1, Paragraph 5 and Section 5.1, Paragraph 2 and Section 7, Paragraph 1
-.67664355

. di "Incapacitation Share = " (14*60000)/(9*615088.4) // Referenced in Section 5.4, Paragraph 3
Incapacitation Share = .15173971

. 
. qui {

. 
. di exp(-0.211)-1 // Referenced in Section 5.1, Paragraph 5
-.19022593

. di exp(-0.280)-1 // Referenced in Section 5.1, Paragraph 5
-.24421626

. 
. qui{

. 
. di exp(-0.286)-1 // Referenced in Section 5.3, Paragraph 1 and Appendix J.2, Bullet 2
-.24873738

. 
. qui {

. 
. 
. *Three treats
. qui gen months_since=0

. qui gen months_since_plot=_n

. 
. foreach var in log_tot_pmt log_rides log_active_firms {
  2.         local suff=""
  3.         if "`var'"=="active_firms" | "`var'"=="log_active_firms" | "`var'"=="ihs_firms" {
  4.                 local suff="_firm"
  5.         }
  6.         qui {
  7.                 estimates clear
  8.                 replace months_since=months_since_civ100`suff'
  9.                 reghdfe `var' ib99.months_since i.prior_auth i.post_crim, a(dist_code month_date) vce(cluster dist_code)
 10.                 gen coef_civ_`var'=e(b)[1,months_since_plot+1]
 11.                 gen coef_civ_`var'll=r(table)[5,months_since_plot+1]
 12.                 gen coef_civ_`var'ul=r(table)[6,months_since_plot+1]
 13.                 replace months_since=months_since_crim100`suff'
 14.                 reghdfe `var' ib99.months_since i.prior_auth i.post_civ, a(dist_code month_date) vce(cluster dist_code)
 15.                 gen coef_crim_`var'=e(b)[1,months_since_plot+1]
 16.                 gen coef_crim_`var'll=r(table)[5,months_since_plot+1]
 17.                 gen coef_crim_`var'ul=r(table)[6,months_since_plot+1]
 18.                 replace months_since=months_since_PA100`suff'
 19.                 reghdfe `var' ib99.months_since i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)
 20.                 gen coef_PA_`var'=e(b)[1,months_since_plot+1]
 21.                 gen coef_PA_`var'll=r(table)[5,months_since_plot+1]
 22.                 gen coef_PA_`var'ul=r(table)[6,months_since_plot+1]
 23.                 
.                 if "`var'"=="log_active_firms" {
 24.                         replace coef_crim_log_active_firms=0.072913 if months_since_plot==1
 25.                         replace coef_crim_log_active_firms=0.1271983 if months_since_plot==2
 26.                         replace coef_crim_log_active_firms=0.0874526 if months_since_plot==3
 27.                         replace coef_crim_log_active_firms=0.0930049 if months_since_plot==4
 28.                         replace coef_crim_log_active_firms=0.1207704 if months_since_plot==5
 29.                         replace coef_crim_log_active_firms=0.0967808 if months_since_plot==6
 30.                         replace coef_crim_log_active_firms=0.1270669 if months_since_plot==7
 31.                         replace coef_crim_log_active_firms=0.0642974 if months_since_plot==8
 32.                         replace coef_crim_log_active_firms=0.0451854 if months_since_plot==9
 33.                         replace coef_crim_log_active_firms=0.0117662 if months_since_plot==10
 34.                         replace coef_crim_log_active_firms=0.0367119 if months_since_plot==11
 35.                         replace coef_crim_log_active_firms=0.0286275 if months_since_plot==12
 36.                         replace coef_crim_log_active_firms=0.0494107 if months_since_plot==13
 37.                         replace coef_crim_log_active_firms=0.0434709 if months_since_plot==14
 38.                         replace coef_crim_log_active_firms=0.0020917 if months_since_plot==15
 39.                         replace coef_crim_log_active_firms=0.0502252 if months_since_plot==16
 40.                         replace coef_crim_log_active_firms=0.110367 if months_since_plot==17
 41.                         replace coef_crim_log_active_firms=0.0458133 if months_since_plot==18
 42.                         replace coef_crim_log_active_firms=0.029368 if months_since_plot==19
 43.                         replace coef_crim_log_active_firms=0.0106828 if months_since_plot==20
 44.                         replace coef_crim_log_active_firms=0.0454713 if months_since_plot==21
 45.                         replace coef_crim_log_active_firms=0.0471174 if months_since_plot==22
 46.                         replace coef_crim_log_active_firms=0.0091867 if months_since_plot==23
 47.                         replace coef_crim_log_active_firms=0.0 if months_since_plot==24
 48.                         replace coef_crim_log_active_firms=0.0364097 if months_since_plot==25
 49.                         replace coef_crim_log_active_firms=0.0516673 if months_since_plot==26
 50.                         replace coef_crim_log_active_firms=0.1021463 if months_since_plot==27
 51.                         replace coef_crim_log_active_firms=-0.0715971 if months_since_plot==28
 52.                         replace coef_crim_log_active_firms=-0.0036712 if months_since_plot==29
 53.                         replace coef_crim_log_active_firms=-0.0984408 if months_since_plot==30
 54.                         replace coef_crim_log_active_firms=-0.0322913 if months_since_plot==31
 55.                         replace coef_crim_log_active_firms=-0.0207831 if months_since_plot==32
 56.                         replace coef_crim_log_active_firms=-0.0500044 if months_since_plot==33
 57.                         replace coef_crim_log_active_firms=-0.0411717 if months_since_plot==34
 58.                         replace coef_crim_log_active_firms=-0.0250933 if months_since_plot==35
 59.                         replace coef_crim_log_active_firms=-0.015885 if months_since_plot==36
 60.                         replace coef_crim_log_active_firms=-0.0667158 if months_since_plot==37
 61.                         replace coef_crim_log_active_firms=-0.0477346 if months_since_plot==38
 62.                         replace coef_crim_log_active_firms=-0.0785844 if months_since_plot==39
 63.                         replace coef_crim_log_active_firms=-0.0526243 if months_since_plot==40
 64.                         replace coef_crim_log_active_firms=-0.0965178 if months_since_plot==41
 65.                         replace coef_crim_log_active_firms=-0.0891376 if months_since_plot==42
 66.                         replace coef_crim_log_active_firms=-0.0865389 if months_since_plot==43
 67.                         replace coef_crim_log_active_firms=-0.0622299 if months_since_plot==44
 68.                         replace coef_crim_log_active_firms=-0.1038087 if months_since_plot==45
 69.                         replace coef_crim_log_active_firms=-0.0849209 if months_since_plot==46
 70.                         replace coef_crim_log_active_firms=-0.0561396 if months_since_plot==47
 71.                         replace coef_crim_log_active_firms=-0.0671494 if months_since_plot==48
 72. 
.                         replace coef_civ_log_active_firms=0.0774507 if months_since_plot==1
 73.                         replace coef_civ_log_active_firms=-0.0106794 if months_since_plot==2
 74.                         replace coef_civ_log_active_firms=-0.0021771 if months_since_plot==3
 75.                         replace coef_civ_log_active_firms=0.0006894 if months_since_plot==4
 76.                         replace coef_civ_log_active_firms=0.0594871 if months_since_plot==5
 77.                         replace coef_civ_log_active_firms=0.0687512 if months_since_plot==6
 78.                         replace coef_civ_log_active_firms=0.0649855 if months_since_plot==7
 79.                         replace coef_civ_log_active_firms=-0.0280148 if months_since_plot==8
 80.                         replace coef_civ_log_active_firms=0.0100127 if months_since_plot==9
 81.                         replace coef_civ_log_active_firms=0.0514865 if months_since_plot==10
 82.                         replace coef_civ_log_active_firms=0.0461303 if months_since_plot==11
 83.                         replace coef_civ_log_active_firms=0.0231952 if months_since_plot==12
 84.                         replace coef_civ_log_active_firms=0.0661827 if months_since_plot==13
 85.                         replace coef_civ_log_active_firms=0.0963315 if months_since_plot==14
 86.                         replace coef_civ_log_active_firms=0.0314718 if months_since_plot==15
 87.                         replace coef_civ_log_active_firms=0.0775342 if months_since_plot==16
 88.                         replace coef_civ_log_active_firms=0.0688942 if months_since_plot==17
 89.                         replace coef_civ_log_active_firms=0.097636 if months_since_plot==18
 90.                         replace coef_civ_log_active_firms=0.1041944 if months_since_plot==19
 91.                         replace coef_civ_log_active_firms=0.0872717 if months_since_plot==20
 92.                         replace coef_civ_log_active_firms=0.0537977 if months_since_plot==21
 93.                         replace coef_civ_log_active_firms=0.0024343 if months_since_plot==22
 94.                         replace coef_civ_log_active_firms=-0.0195693 if months_since_plot==23
 95.                         replace coef_civ_log_active_firms=0.0 if months_since_plot==24
 96.                         replace coef_civ_log_active_firms=0.0157049 if months_since_plot==25
 97.                         replace coef_civ_log_active_firms=-0.0085397 if months_since_plot==26
 98.                         replace coef_civ_log_active_firms=0.0263144 if months_since_plot==27
 99.                         replace coef_civ_log_active_firms=0.018989 if months_since_plot==28
100.                         replace coef_civ_log_active_firms=0.0298541 if months_since_plot==29
101.                         replace coef_civ_log_active_firms=0.0761345 if months_since_plot==30
102.                         replace coef_civ_log_active_firms=0.0492703 if months_since_plot==31
103.                         replace coef_civ_log_active_firms=0.0146894 if months_since_plot==32
104.                         replace coef_civ_log_active_firms=0.0532449 if months_since_plot==33
105.                         replace coef_civ_log_active_firms=-0.0274861 if months_since_plot==34
106.                         replace coef_civ_log_active_firms=-0.0402403 if months_since_plot==35
107.                         replace coef_civ_log_active_firms=-0.0130546 if months_since_plot==36
108.                         replace coef_civ_log_active_firms=-0.0783442 if months_since_plot==37
109.                         replace coef_civ_log_active_firms=-0.0194587 if months_since_plot==38
110.                         replace coef_civ_log_active_firms=-0.0313874 if months_since_plot==39
111.                         replace coef_civ_log_active_firms=-0.0415347 if months_since_plot==40
112.                         replace coef_civ_log_active_firms=-0.0027668 if months_since_plot==41
113.                         replace coef_civ_log_active_firms=0.0269179 if months_since_plot==42
114.                         replace coef_civ_log_active_firms=0.0484709 if months_since_plot==43
115.                         replace coef_civ_log_active_firms=-0.0014068 if months_since_plot==44
116.                         replace coef_civ_log_active_firms=0.053352 if months_since_plot==45
117.                         replace coef_civ_log_active_firms=0.0774887 if months_since_plot==46
118.                         replace coef_civ_log_active_firms=0.053352 if months_since_plot==47
119.                         replace coef_civ_log_active_firms=0.0155726 if months_since_plot==48
120.                 }
121.         }
122.         if "`var'"=="log_tot_pmt" {
123.                 twoway (line coef_civ_log_tot_pmt months_since_plot) ///
>                         (line coef_crim_log_tot_pmt months_since_plot, lpatt(shortdash)) ///
>                         (line coef_PA_log_tot_pmt months_since_plot, lpatt(longdash)) ///
>                         (pcarrowi -0.775 32.5 -0.85 31.5, color(black)) ///
>                         (pcarrowi -0.35 34.5 -0.275 35, color(black)) ///
>                         (pcarrowi 0.11 35.2 0.06 34.5, color(black)) if months_since_plot<49, ///
>                         text(-0.75 32.5 "Prior Authorization", placement(e)) ///
>                         text(-0.4 26 "Criminal Enforcement", placement(e)) ///
>                         text(0.17 33 "Civil Enforcement", placement(e)) ///
>                         xti(Months Since Enforcement) ///
>                         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                                 31 "6" 37 "12" 43 "18" 49 "24") ///
>                         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>                         yti("Total Payments in District (Logs)") ///
>                         ylab(, nogrid angle(0)) leg(off) ///
>                         graphregion(color(white)) bgcolor(white) ///
>                         aspect(0.525) ysize(9) xsize(16)
124.                 qui graph export ${outpath}Figure_5.pdf, as(pdf) replace // Figure 5
125.         }
126.         if "`var'"!="log_tot_pmt" {
127.                 twoway (line coef_civ_`var' months_since_plot) ///
>                         (line coef_crim_`var' months_since_plot, lpatt(shortdash)) ///
>                         (line coef_PA_`var' months_since_plot, lpatt(longdash)) if months_since_plot<49, ///
>                         xti(Months Since Enforcement) ///
>                         xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
>                                 31 "6" 37 "12" 43 "18" 49 "24") ///
>                         xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
>                         yti("`:variable label `var''") ///
>                         ylab(, nogrid angle(0)) ///
>                         leg(order(1 "Civil Enforcement" 2 "Criminal Enforcement" 3 "Prior Authorization")) ///
>                         graphregion(color(white)) bgcolor(white) ///
>                         aspect(0.525) ysize(9) xsize(16)
128.                 if "`var'"=="log_rides" {
129.                         qui graph export ${outpath}Figure_A18a.pdf, as(pdf) replace // Figure A18a
130.                 }
131.                 if "`var'"=="log_active_firms" {
132.                         qui graph export ${outpath}Figure_A18b.pdf, as(pdf) replace // Figure A18b
133.                 }
134.         }
135. }

. 
. 
. log close
      name:  <unnamed>
       log:  X:\shared\ambulance\Work\replicationpackage\logs\district_regressions.log
  log type:  text
 closed on:  13 Jul 2024, 07:41:12
--------------------------------------------------------------------------------------------------------------------------------------------------------
